<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;

use App\Services\BackgroundService;
use Illuminate\Http\Request;


//背景图
class BackgroundController extends Controller{

    public $request;
    public $BackgroundService;

    public function __construct(Request $request,BackgroundService $background)
    {
        $this->request = $request;
        $this->BackgroundService = $background;
    }


    public function index(){
        $data = $this->BackgroundService->getBackgroundList();
        return view("admin.background.index")->with('data',$data['data']);


    }
    public function edit($id){
        $req_result = $this->BackgroundService->getBackground($id);
        return view("admin.background.edit")->with('data',$req_result['data']);
    }
    public function update()
    {
        $data   = $this->request->all();
        $req_result = $this->BackgroundService->updateBackground($data);
        if($req_result['success']){
            return redirect('/admin/background');
        }else{
            return back()->withErrors([$req_result['msg']])->withInput();
        }

    }
}
